{ open Parser }

let letter = ['a'-'z' 'A'-'Z']
let digit = ['0'-'9']

rule token = parse
	  [' ' '\t' 'r' '\n']				{ token lexbuf }
	| "/*"						{ comment lexbuf }
	| ';'						{ EOL }
	| eof						{ EOF }
	(* *)
	| ','						{ COMMA }
	| '('						{ LPAREN }
	| ')'						{ RPAREN }
	| '{'						{ LBRACE }
	| '}'						{ RBRACE }
	(* literal *)
	| digit+ as num					{ INT(int_of_string num) }
	| "true"					{ BOOL("true") }
	| "false"					{ BOOL("false") }
	| '"'(([^'"']|"\\\"")* as str)'"'		{ STRING(str) }
	| letter (letter|digit|'_')* as name		{ NAME(name) }
        (* datatype *)
        | "void"                                        { DATATYPE("void") }
        | "int"                                         { DATATYPE("int") }
	| "bool"					{ DATATYPE("bool") }
        | "string"                                      { DATATYPE("string") }
        | "Point"                                       { DATATYPE("Point") }
	(* operations *)
	| '='						{ ASSIGN }
	| '+'						{ PLUS }
	| '-'						{ MINUS }
	| '*'						{ TIMES }
	| '/'						{ DIVIDE }
	(* *)
	| '>'						{ GT }
	| ">="						{ GTEQ }
	| '<'						{ LT }
	| "<="						{ LTEQ }
	| "=="						{ EQ }
	| "!="						{ NEQ }
	| "&&"						{ AND }
	| "||"						{ OR }
	| '!'						{ NOT }
	| "if"						{ IF }
	| "else"					{ ELSE }
	| "for"						{ FOR }
	| "while"					{ WHILE }
	| "continue"					{ CONTINUE }
	| "break"					{ BREAK }
	| "return"					{ RETURN }
	(* keywords *)
	(* functions *)

and comment = parse
	  "*/"						{ token lexbuf}
	| _						{ comment lexbuf }

